#include<stdio.h>
#include<conio.h>
#include<math.h>
struct phanso
{
       int tu,mau;
};
void nhap(phanso &s)
{
     printf("\n nhap tu so");
     scanf("%d",&s.tu);
     printf("\n nhap mau so");
     scanf("%d",&s.mau);
}
void xuat(phanso s)
{
     printf("\n phan so vua nhap la:");
     printf("%d/%d",s.tu,s.mau);
} 
int ucln(int x,int y)
{
  if(y==0)return x; 
  else return ucln(y,x%y);  
}
void rutgon(phanso s)
{
     int uc;
     uc=ucln(s.tu,s.mau);
     s.tu=s.tu/uc;
     s.mau=s.mau/uc;
     printf("\n pso sau khi rut gon la:%d/%d",s.tu,s.mau);
}
phanso tong(phanso a,phanso b)
{
       phanso kq;
       kq.tu=a.tu*b.mau+a.mau*b.tu;
       kq.mau=a.mau*b.mau;
       return kq;
}
int main()
{
 phanso x;
 phanso y;
 nhap(x);
 xuat(x);
 nhap(y);
 xuat(y);
 rutgon(x);
 rutgon(tong(x,y));
 printf("\n tong 2 pso la %d/%d",tong(x,y));
    getch();
}
